<template>
	<view class="box">
		<image v-if="Error" class="icon" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/common/avatar@2x.png"
			mode="aspectFit"></image>
		<image v-else class="icon" :src="src" mode="aspectFit" @error="Error = true"></image>
	</view>
</template>

<script>
	export default {
		name: "avatar",
		props: {
			src: {
				type: String,
			}
		},
		data() {
			return {
				Error: false,
			};
		},

	}
</script>

<style lang="scss" scoped>
	.box {
		width: 100%;
		height: 100%;

		.icon {
			display: block;
			width: 100%;
			height: 100%;
		}
	}
</style>
